package work.person;

import work.fram.AutoSqlWriter;
import work.utils.TextUtils;

public class SqlHandler {

//    private static Statement statement = JDBCConnect.getStatement();


    private static AutoSqlWriter autoSqlWriter = AutoSqlWriter.INSTANCE;

    private static boolean flag = true;

    private static int maxLen = 100 * 10000;

    private static StringBuilder builder = new StringBuilder();

    public static void handle(String sql) {


        try {

            try {
                System.out.println(sql);

                autoSqlWriter.write("插入", sql);
/*
                if (flag) {
                    if (builder.length() < maxLen) {
                        builder.append(sql).append("\n");
                    } else {
                        flag = false;
                    }
                }*/

                // statement.execute(sql);
            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("无法执行的sql:" + sql);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void close() {

        autoSqlWriter.close();
/*
        if (flag) {
            TextUtils.textToClipboard(builder.toString());
            System.out.println("提示:sql已写入粘贴板");
        }*/

    }

}
